package com.ctg.polling.domain.util.openid;

import java.util.ArrayList;
import java.util.Collection;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

/**
 * Contains the information related to an user authentication.
 * @author jibe
 *
 */
public class UserDetailsPolling implements UserDetails {

	private String username;
	
	public UserDetailsPolling(String username) {
		this.username = username;
	}

	@Override
	public Collection<GrantedAuthority> getAuthorities() {
		Collection<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
		if (username.equals("http://jibe77.myopenid.com/")
				|| username.equals("http://www.google.com/profiles/cdemulder")
				|| username.equals("http://www.google.com/profiles/laurent.untereiner")) {
			authorities.add(new RoleUser());
		}
		return authorities;
	}

	@Override
	public String getPassword() {
		return "";
	}

	@Override
	public String getUsername() {
		return username;
	}

	@Override
	public boolean isAccountNonExpired() {
		return true;
	}

	@Override
	public boolean isAccountNonLocked() {
		return true;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		return true;
	}

	@Override
	public boolean isEnabled() {
		return true;
	}

}
